# Maintainer: Jaroslav Lichtblau <svetlemodry@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: Tom Newsom <Jeepster@gmx.co.uk>

pkgname=lbreakout2
pkgver=2.6.5
pkgrel=3
pkgdesc="A breakout game with nice effects, graphics, and sounds"
arch=('loong64' 'x86_64')
url="http://lgames.sourceforge.net"
license=('GPL')
depends=('sdl_mixer' 'libpng')
makedepends=('patch')
backup=('var/games/lbreakout2/lbreakout2.hscr')
source=(https://downloads.sourceforge.net/lgames/${pkgname}-${pkgver/_/-}.tar.gz
        lbreakout2.desktop lbreakout2.png
        https://salsa.debian.org/games-team/lbreakout2/raw/60e3e5339b073e12f1eb93d08dd48dfe17c35060/debian/patches/sdl_fix_pauses.patch)
sha256sums=('9104d6175553da3442dc6a5fc407a669e2f5aff3eedc5d30409eb003b7a78d6f'
            '43848f4739c6669f5c83d5944a797ca176615364006426304851d28c50dab46d'
            'ece97aed58848bfec08f6b91123cb3dd234f969e0ce66c3b51fd6bcaa4840ef4'
            '2ac4a227fd2bac6e14fcaa2797520fdbb6c161a62b0bca349fe449499f80bc03')

prepare() {
  cd "${srcdir}"/${pkgname}-${pkgver/_/-}

  patch -Np1 -i "${srcdir}"/sdl_fix_pauses.patch
}

build() {
  cd "${srcdir}"/${pkgname}-${pkgver/_/-}

  ./configure --prefix=/usr --localstatedir=/var/games/lbreakout2 
  make
}

package() {
  cd "${srcdir}"/${pkgname}-${pkgver/_/-}

  make DESTDIR="${pkgdir}"/ doc_dir=/usr/share/doc install
  
  chmod -R 755 "${pkgdir}"/usr
  chown root:games "${pkgdir}"/var/games
  chmod 775 "${pkgdir}"/var/games
  chown root:games "${pkgdir}"/var/games/lbreakout2
  chmod 755 "${pkgdir}"/var/games/lbreakout2
  chown root:games "${pkgdir}"/var/games/lbreakout2/lbreakout2.hscr
  chmod 775 "${pkgdir}"/var/games/lbreakout2/lbreakout2.hscr

  install -Dm644 ${srcdir}/lbreakout2.png "${pkgdir}"/usr/share/pixmaps/lbreakout2.png
  install -Dm644 ${srcdir}/lbreakout2.desktop "${pkgdir}"/usr/share/applications/lbreakout2.desktop
}
